TestOverload.cs

    using UnityEngine;
    using System.Collections;
    using LuaInterface;
    using System;
    using System.Reflection;

    public class TestEnum
    {
        public TestEnum()
        {

        }

        public void Test(UnityEngine.Space e)
        {

        }
    }

    public class TestExport
    {
        [LuaByteBufferAttribute]
        public delegate void TestBuffer(byte[] buffer);       

        public enum Space
        {
            World = 1
        }

        public int field = 1024;

        public System.Action OnClick = delegate { };

        public delegate void TestRefEvent(ref GameObject go);

        public TestRefEvent OnRefEvent;

        //public int Item { get; set; }
        private int number = 123;
        public int Number
        {
            get
            {            
                return number;
            }

            set
            {            
                number = value;            
            }
        }

        public int this[int pos]
        {
            get { return pos; }
            set { Debugger.Log(value); }
        }

        [LuaByteBufferAttribute]
        public byte[] buffer;

        public static int get_Item(string pos) { return 0; }
        public static int get_Item(double pos) { return 0; }

        public static int set_Item(double pos) { return 0; }

        public void TestByteBuffer(TestBuffer tb)
        {

        }

        public int Test(object o, string str)
        {
            Debugger.Log("call Test(object o, string str)");
            return 1;
        }

        [LuaRenameAttribute(Name = "TestChar")]
        public int Test(char c)
        {
            Debugger.Log("call Test(char c)");
            return 2;
        }

        public int Test(bool b)
        {
            Debugger.Log("call Test(bool b)");
            return 15;
        }

        public int Test(int[,] objs)
        {
            Debugger.Log("call Test(int[,] objs)");
            return 16;
        }

        public int Test(int i)
        {
            Debugger.Log("call Test(int i)");
            return 3;
        }

        //有这个函数要扔掉上面两个精度不匹配的,因为lua是double
        public int Test(double d)
        {
            Debugger.Log("call Test(double d)");
            return 4;
        }

        public int Test(out int i)
        {
            i = 1024;
            Debugger.Log("call Test(ref int i)");
            return 3;
        }


        public int Test(int i, int j)
        {
            Debugger.Log("call Test(int i, int j)");
            return 5;
        }


        public int Test(string str)
        {
            Debugger.Log("call Test(string str)");
            return 6;
        }

        public static int Test(string str1, string str2)
        {
            Debugger.Log("call static Test(string str1, string str2)");
            return 7;
        }

        public int Test(object o)
        {
            Debugger.Log("call Test(object o)");
            return 8;
        }    

        public int Test(params int[] objs)
        {
            Debugger.Log("call Test(params int[] objs)");
            return 12;
        }

        public int Test(params string[] objs)
        {
            Debugger.Log("call Test(params int[] objs)");
            return 13;
        }

        public int Test(params object[] objs)
        {
            Debugger.Log("call Test(params object[] objs)");
            return 9;
        }

        public int Test(Space e)
        {
            Debugger.Log("call Test(Space e)");
            return 10;
        }

        public int Test33(ref System.Action<int> action)
        {
            Debugger.Log("ref System.Action action");
            return 14;
        }

        public int TestGeneric<T> (T t) where T : Component
        {
            Debugger.Log("TestGeneric(T t) Call");
            return 11;
        }

        public int TestEnum(Space e)
        {
            Debugger.Log("call TestEnum(Space e)");
            return 10;
        }

        public int TestCheckParamNumber(params int[] ns)
        {
            Debugger.Log("call TestCheckParamNumber(params int[] ns)");
            int n = 0;

            for (int i = 0; i < ns.Length; i++)
            {
                n += ns[i];
            }

            return n;
        }

        public string TestCheckParamString(params string[] ss)
        {
            Debugger.Log("call TestCheckParamNumber(params string[] ss)");
            string str = null;

            for (int i = 0; i < ss.Length; i++)
            {
                str += ss[i];
            }

            return str;
        }

        public static void TestReflection()
        {
            Debugger.Log("call TestReflection()");        
        }

        public static void TestRefGameObject(ref GameObject go)
        {

        }

        public void DoClick()
        {
            OnClick();
        }

        public TestExport()
        {
            Debugger.Log("call TestExport()");
        }

        public TestExport(Vector3[] v)
        {
            Debugger.Log("call TestExport(params Vector3[] v)");
        }

        public TestExport(Vector3 v, string str)
        {
            Debugger.Log("call TestExport(Vector3 v, string str)");
        }

        public TestExport(Vector3 v)
        {
            Debugger.Log("call TestExport(Vector3 v)");
        }
    }

    public class TestOverload : MonoBehaviour
    {
        private string script =
    @"                  
            require 'TestExport'                                        
            local out = require 'tolua.out'
            local GameObject = UnityEngine.GameObject                                

            function Test(to)            
                assert(to:Test(1) == 4)            
                local flag, num = to:Test(out.int)
                assert(flag == 3 and num == 1024, 'Test(out)')
                assert(to:Test('hello') == 6, 'Test(string)')
                assert(to:Test(System.Object.New()) == 8)            
                assert(to:Test(true) == 15)
                assert(to:Test(123, 456) == 5)            
                assert(to:Test('123', '456') == 1)
                assert(to:Test(System.Object.New(), '456') == 1)
                assert(to:Test('123', 456) == 9)
                assert(to:Test('123', System.Object.New()) == 9)
                assert(to:Test(1,2,3) == 12)            
                assert(to:TestGeneric(GameObject().transform) == 11)
                assert(to:TestCheckParamNumber(1,2,3) == 6)
                assert(to:TestCheckParamString('1', '2', '3') == '123')
                assert(to:Test(TestExport.Space.World) == 10)        
                print(to.this:get(123))
                to.this:set(1, 456)           
            end
        ";

        void Awake ()
        {
            LuaState state = new LuaState();
            state.Start();
            LuaBinder.Bind(state);
            Bind(state);
            state.DoString(script, "TestOverload.cs");

            TestExport to = new TestExport();
            LuaFunction func = state.GetFunction("Test");
            func.Call(to);          
            state.Dispose();                     
        }

        void Bind(LuaState state)
        {
            state.BeginModule(null);
            TestExportWrap.Register(state);
            state.BeginModule("TestExport");
            TestExport_SpaceWrap.Register(state);
            state.EndModule();
            state.EndModule();
        }
    }

TestExportWrap.cs

    //this source code was auto-generated by tolua#, do not modify it
    using System;
    using LuaInterface;

    public class TestExportWrap
    {
        public static void Register(LuaState L)
        {
            L.BeginClass(typeof(TestExport), typeof(System.Object));
            L.RegFunction(".geti", get_Item);
            L.RegFunction("get_Item", get_Item);
            L.RegFunction(".seti", set_Item);
            L.RegFunction("set_Item", set_Item);
            L.RegFunction("TestByteBuffer", TestByteBuffer);
            L.RegFunction("Test", Test);
            L.RegFunction("TestChar", TestChar);
            L.RegFunction("Test33", Test33);
            L.RegFunction("TestGeneric", TestGeneric);
            L.RegFunction("TestEnum", TestEnum);
            L.RegFunction("TestCheckParamNumber", TestCheckParamNumber);
            L.RegFunction("TestCheckParamString", TestCheckParamString);
            L.RegFunction("TestReflection", TestReflection);
            L.RegFunction("TestRefGameObject", TestRefGameObject);
            L.RegFunction("DoClick", DoClick);
            L.RegFunction("New", _CreateTestExport);
            L.RegVar("this", _this, null);
            L.RegFunction("__tostring", ToLua.op_ToString);
            L.RegVar("field", get_field, set_field);
            L.RegVar("OnClick", get_OnClick, set_OnClick);
            L.RegVar("OnRefEvent", get_OnRefEvent, set_OnRefEvent);
            L.RegVar("buffer", get_buffer, set_buffer);
            L.RegVar("Number", get_Number, set_Number);
            L.RegFunction("TestBuffer", TestExport_TestBuffer);
            L.RegFunction("TestRefEvent", TestExport_TestRefEvent);
            L.EndClass();
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _CreateTestExport(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);

                if (count == 0)
                {
                    TestExport obj = new TestExport();
                    ToLua.PushObject(L, obj);
                    return 1;
                }
                else if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Vector3)))
                {
                    UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
                    TestExport obj = new TestExport(arg0);
                    ToLua.PushObject(L, obj);
                    return 1;
                }
                else if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Vector3[])))
                {
                    UnityEngine.Vector3[] arg0 = ToLua.CheckObjectArray<UnityEngine.Vector3>(L, 1);
                    TestExport obj = new TestExport(arg0);
                    ToLua.PushObject(L, obj);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Vector3), typeof(string)))
                {
                    UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
                    string arg1 = ToLua.CheckString(L, 2);
                    TestExport obj = new TestExport(arg0, arg1);
                    ToLua.PushObject(L, obj);
                    return 1;
                }
                else
                {
                    return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: TestExport.New");
                }
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _get_this(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 2);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int o = obj[arg0];
                LuaDLL.lua_pushinteger(L, o);
                return 1;

            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _set_this(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 3);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                obj[arg0] = arg1;
                return 0;

            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _this(IntPtr L)
        {
            try
            {
                LuaDLL.lua_pushvalue(L, 1);
                LuaDLL.tolua_bindthis(L, _get_this, _set_this);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_Item(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);

                if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(double)))
                {
                    double arg0 = (double)LuaDLL.lua_tonumber(L, 1);
                    int o = TestExport.get_Item(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(string)))
                {
                    string arg0 = ToLua.ToString(L, 1);
                    int o = TestExport.get_Item(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(int)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                    int o = obj[arg0];
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else
                {
                    return LuaDLL.luaL_throw(L, "invalid arguments to method: TestExport.get_Item");
                }
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int set_Item(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);

                if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(double)))
                {
                    double arg0 = (double)LuaDLL.lua_tonumber(L, 1);
                    int o = TestExport.set_Item(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(int), typeof(int)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                    int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                    obj[arg0] = arg1;
                    return 0;
                }
                else
                {
                    return LuaDLL.luaL_throw(L, "invalid arguments to method: TestExport.set_Item");
                }
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestByteBuffer(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 2);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                TestExport.TestBuffer arg0 = null;
                LuaTypes funcType2 = LuaDLL.lua_type(L, 2);

                if (funcType2 != LuaTypes.LUA_TFUNCTION)
                {
                     arg0 = (TestExport.TestBuffer)ToLua.CheckObject(L, 2, typeof(TestExport.TestBuffer));
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    arg0 = DelegateFactory.CreateDelegate(typeof(TestExport.TestBuffer), func) as TestExport.TestBuffer;
                }

                obj.TestByteBuffer(arg0);
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int Test(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);

                if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(string)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    string arg0 = ToLua.ToString(L, 2);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(LuaInterface.LuaOut<int>)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    int arg0;
                    int o = obj.Test(out arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    LuaDLL.lua_pushinteger(L, arg0);
                    return 2;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(TestExport.Space)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    TestExport.Space arg0 = (TestExport.Space)ToLua.ToObject(L, 2);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(string)))
                {
                    string arg0 = ToLua.ToString(L, 1);
                    string arg1 = ToLua.ToString(L, 2);
                    int o = TestExport.Test(arg0, arg1);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(int[,])))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    int[,] arg0 = (int[,])ToLua.ToObject(L, 2);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(bool)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    bool arg0 = LuaDLL.lua_toboolean(L, 2);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(double)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    double arg0 = (double)LuaDLL.lua_tonumber(L, 2);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(object)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    object arg0 = ToLua.ToVarObject(L, 2);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(int), typeof(int)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                    int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                    int o = obj.Test(arg0, arg1);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(TestExport), typeof(object), typeof(string)))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    object arg0 = ToLua.ToVarObject(L, 2);
                    string arg1 = ToLua.ToString(L, 3);
                    int o = obj.Test(arg0, arg1);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (TypeChecker.CheckParamsType(L, typeof(string), 2, count - 1))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    string[] arg0 = ToLua.ToParamsString(L, 2, count - 1);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (TypeChecker.CheckParamsType(L, typeof(int), 2, count - 1))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    int[] arg0 = ToLua.ToParamsNumber<int>(L, 2, count - 1);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else if (TypeChecker.CheckParamsType(L, typeof(object), 2, count - 1))
                {
                    TestExport obj = (TestExport)ToLua.ToObject(L, 1);
                    object[] arg0 = ToLua.ToParamsObject(L, 2, count - 1);
                    int o = obj.Test(arg0);
                    LuaDLL.lua_pushinteger(L, o);
                    return 1;
                }
                else
                {
                    return LuaDLL.luaL_throw(L, "invalid arguments to method: TestExport.Test");
                }
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestChar(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 2);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                char arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
                int o = obj.Test(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int Test33(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 2);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                System.Action<int> arg0 = null;
                LuaTypes funcType2 = LuaDLL.lua_type(L, 2);

                if (funcType2 != LuaTypes.LUA_TFUNCTION)
                {
                     arg0 = (System.Action<int>)ToLua.CheckObject(L, 2, typeof(System.Action<int>));
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    arg0 = DelegateFactory.CreateDelegate(typeof(System.Action<int>), func) as System.Action<int>;
                }

                int o = obj.Test33(ref arg0);
                LuaDLL.lua_pushinteger(L, o);
                ToLua.Push(L, arg0);
                return 2;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestGeneric(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 2);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                UnityEngine.Component arg0 = (UnityEngine.Component)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Component));
                int o = obj.TestGeneric(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestEnum(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 2);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                TestExport.Space arg0 = (TestExport.Space)ToLua.CheckObject(L, 2, typeof(TestExport.Space));
                int o = obj.TestEnum(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestCheckParamNumber(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                int[] arg0 = ToLua.CheckParamsNumber<int>(L, 2, count - 1);
                int o = obj.TestCheckParamNumber(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestCheckParamString(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                string[] arg0 = ToLua.CheckParamsString(L, 2, count - 1);
                string o = obj.TestCheckParamString(arg0);
                LuaDLL.lua_pushstring(L, o);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestReflection(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 0);
                TestExport.TestReflection();
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestRefGameObject(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 1);
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.GameObject));
                TestExport.TestRefGameObject(ref arg0);
                ToLua.Push(L, arg0);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int DoClick(IntPtr L)
        {
            try
            {
                ToLua.CheckArgsCount(L, 1);
                TestExport obj = (TestExport)ToLua.CheckObject(L, 1, typeof(TestExport));
                obj.DoClick();
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_field(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                int ret = obj.field;
                LuaDLL.lua_pushinteger(L, ret);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index field on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_OnClick(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                System.Action ret = obj.OnClick;
                ToLua.Push(L, ret);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OnClick on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_OnRefEvent(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                TestExport.TestRefEvent ret = obj.OnRefEvent;
                ToLua.Push(L, ret);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OnRefEvent on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_buffer(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                byte[] ret = obj.buffer;
                LuaDLL.tolua_pushlstring(L, ret, ret.Length);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index buffer on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_Number(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                int ret = obj.Number;
                LuaDLL.lua_pushinteger(L, ret);
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Number on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int set_field(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                obj.field = arg0;
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index field on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int set_OnClick(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                System.Action arg0 = null;
                LuaTypes funcType2 = LuaDLL.lua_type(L, 2);

                if (funcType2 != LuaTypes.LUA_TFUNCTION)
                {
                     arg0 = (System.Action)ToLua.CheckObject(L, 2, typeof(System.Action));
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    arg0 = DelegateFactory.CreateDelegate(typeof(System.Action), func) as System.Action;
                }

                obj.OnClick = arg0;
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OnClick on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int set_OnRefEvent(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                TestExport.TestRefEvent arg0 = null;
                LuaTypes funcType2 = LuaDLL.lua_type(L, 2);

                if (funcType2 != LuaTypes.LUA_TFUNCTION)
                {
                     arg0 = (TestExport.TestRefEvent)ToLua.CheckObject(L, 2, typeof(TestExport.TestRefEvent));
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    arg0 = DelegateFactory.CreateDelegate(typeof(TestExport.TestRefEvent), func) as TestExport.TestRefEvent;
                }

                obj.OnRefEvent = arg0;
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OnRefEvent on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int set_buffer(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                byte[] arg0 = ToLua.CheckByteBuffer(L, 2);
                obj.buffer = arg0;
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index buffer on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int set_Number(IntPtr L)
        {
            object o = null;

            try
            {
                o = ToLua.ToObject(L, 1);
                TestExport obj = (TestExport)o;
                int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                obj.Number = arg0;
                return 0;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Number on a nil value" : e.Message);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestExport_TestBuffer(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);
                LuaFunction func = ToLua.CheckLuaFunction(L, 1);

                if (count == 1)
                {
                    Delegate arg1 = DelegateFactory.CreateDelegate(typeof(TestExport.TestBuffer), func);
                    ToLua.Push(L, arg1);
                }
                else
                {
                    LuaTable self = ToLua.CheckLuaTable(L, 2);
                    Delegate arg1 = DelegateFactory.CreateDelegate(typeof(TestExport.TestBuffer), func, self);
                    ToLua.Push(L, arg1);
                }
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int TestExport_TestRefEvent(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);
                LuaFunction func = ToLua.CheckLuaFunction(L, 1);

                if (count == 1)
                {
                    Delegate arg1 = DelegateFactory.CreateDelegate(typeof(TestExport.TestRefEvent), func);
                    ToLua.Push(L, arg1);
                }
                else
                {
                    LuaTable self = ToLua.CheckLuaTable(L, 2);
                    Delegate arg1 = DelegateFactory.CreateDelegate(typeof(TestExport.TestRefEvent), func, self);
                    ToLua.Push(L, arg1);
                }
                return 1;
            }
            catch(Exception e)
            {
                return LuaDLL.toluaL_exception(L, e);
            }
        }
    }

TestExport_SpaceWrap.cs

    //this source code was auto-generated by tolua#, do not modify it
    using System;
    using LuaInterface;

    public class TestExport_SpaceWrap
    {
        public static void Register(LuaState L)
        {
            L.BeginEnum(typeof(TestExport.Space));
            L.RegVar("World", get_World, null);
            L.RegFunction("IntToEnum", IntToEnum);
            L.EndEnum();
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int get_World(IntPtr L)
        {
            ToLua.Push(L, TestExport.Space.World);
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int IntToEnum(IntPtr L)
        {
            int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
            TestExport.Space o = (TestExport.Space)arg0;
            ToLua.Push(L, o);
            return 1;
        }
    }

🔚

results matching ""

    No results matching ""